package threading.tests;

import jccr.*;

import org.junit.*;

public class PortTests extends Assert {

	@Test
	public void postString() {
		
		StringPort port = new StringPort();
		port.enqueue("postString");
		
		execute(port);
	}
	
	class StringPort extends Port<String> {
		
		@Override
		public void execute( String arg ) {	
			System.out.println(arg);
		}
	}
	
	@Test
	public void postInt() {
		
		IntPort port = new IntPort();
		port.enqueue(1);
		
		execute(port);
	}
	
	class IntPort extends Port<Integer> {
		
		@Override
		public void execute( Integer arg ) {
			int i = 99;
			System.out.println(arg + i);
		}
	}
	
	void execute( RawPort port ) {
		
		Object arg = port.dequeueRaw();
		port.executeRaw(arg);
	}
}
